package com.yan.arrays;

public class Test4 {
    public static void main(String[] args) {
        int count5 = fiveBit();
        System.out.println(count5);
        int count7 = sevenBit();
        System.out.println("count7 = " + count7);
        System.out.println("相差"+(count7 - count5)+"个");
    }

    public static int fiveBit(){
        int count = 0;
        int[] arr = new int[5];
        for (int i = 10000; i < 100000; i++) {
            int num = i;
            for (int j = arr.length - 1; j >= 0; j--) {
                arr[j] = num % 10;
                num /= 10;
            }
            // 1  2  3  2  1
            // 0  1  2  3  4
                if(arr[0] == arr[4] && arr[1] == arr[3]){
                    count++;
            }
        }
        return count;
    }

    public static int sevenBit(){
        int count = 0;
        int[] arr = new int[7];
        for (int i = 1000000; i < 10000000; i++) {
            int num = i;
            for (int j = arr.length - 1; j >= 0; j--) {
                arr[j] = num % 10;
                num /= 10;
            }
            // 1  2  3  4  3  2  1
            // 0  1  2  3  4  5  6
            if(arr[0] == arr[6] && arr[1] == arr[5] && arr[2] == arr[4]){
                count++;
            }
        }
        return count;
    }
}
